package com.example.imtoken.core.binding

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.example.imtoken.core.utils.MyImageLoaderUtils
import com.example.imtoken.core.utils.StatusManageUtils

object ImageViewBindingAdapter {

    @JvmStatic
    @BindingAdapter("image")
    fun setImage(imageView: ImageView, url: String?) {
        if (url == null) return
        MyImageLoaderUtils.loadRound(imageView.context, url, imageView)
    }

    @JvmStatic
    @BindingAdapter("imageResId")
    fun setImageResId(imageView: ImageView, iconResId: Int) {
        imageView.setImageResource(iconResId)
    }

    @JvmStatic
    @BindingAdapter("imageStatus")
    fun setImageStatus(imageView: ImageView, status: Boolean) {
        StatusManageUtils.statusImageView(imageView, status)
    }

    @JvmStatic
    @BindingAdapter("imageAddToken")
    fun setImageAddToken(imageView: ImageView, status: Int) {
        StatusManageUtils.addTokenImageView(imageView, status)
    }

    @JvmStatic
    @BindingAdapter("imageRecord")
    fun setImageRecordStatus(imageView: ImageView, type: Int) {
        StatusManageUtils.transactionRecord(imageView, type)
    }

    @JvmStatic
    @BindingAdapter("imageDetails")
    fun setImageTransactionDetailsStatus(imageView: ImageView, status: Int) {
        StatusManageUtils.transactionDetailsStatus(imageView, status)
    }

}